package com.example.userpointmgr.controller;

import com.example.userpointmgr.dao.ConfirmDto;
import com.example.userpointmgr.dao.ReviewAddDto;
import com.example.userpointmgr.dao.ReviewDto;
import com.example.userpointmgr.service.ReviewService;
import com.example.userpointmgr.tool.PageParam;
import com.example.userpointmgr.tool.ResponseResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/review")
public class ReviewController {
    @Autowired
    private ReviewService reviewService;

    @GetMapping("/reviewlist")
    @ApiOperation("获取全部审核信息，按照提交时间先后顺序")
    public ResponseResult findAll(@RequestParam Integer pageNum, @RequestParam Integer pageSize){
        PageParam pageParam=new PageParam(pageNum,pageSize);
        return ResponseResult.success(reviewService.findAllUsers(pageParam));
    }
    @PostMapping("/updateReview")
    @ApiOperation("审核信息,就是更新审核状态")
    public ResponseResult review(@RequestBody ReviewDto reviewDto){

        return ResponseResult.success(reviewService.updateReview(reviewDto));
    }
    @PostMapping("/addreview")
    @ApiOperation("新建审核")
    public ResponseResult addReview(@RequestBody ReviewAddDto reviewAddDto){

        return ResponseResult.success(reviewService.addReview(reviewAddDto));
    }
    //修改积分质控和部长都能用的接口
    @PostMapping("/editorPoint")
    @ApiOperation("修改积分")
    public ResponseResult updatePoint(@RequestBody ConfirmDto confirmDto){
    return ResponseResult.success(reviewService.updatePoint(confirmDto));
    }
}
